<?php
class OrderController extends AppController {
	var $name = 'Order';
	var $helpers = array('Html');
	var $components = array('Init', 'Param');
	var $uses = null;

	function beforeFilter() {
		if (!$this->Session->read('admin')) {
			$this->redirect('/users/login');
		}
		else {
			$this->Init->startup($this);
			$this->Admin = $this->Init->init();

			$this->set('dashboard',0);
			$this->set('content',0);
			$this->set('products',0);
			$this->set('component',1);
			$this->set('system',0);

			$this->set('title','Member Management');
			$this->set('sub_title', $this->Param->getAction($this->params));
  		}
	}

	function index(){
		$this->loadModel('Order');
		$pictures = $this->Order->find('all', array(
										'order' 	 => array('Order.date desc')
										));
		$this->set('members',$pictures);
	}
	
	function edit($id = null) {
		$this->loadModel('Order');
		$this->Order->loadDetail();
		if ($id == null) {
			$this->redirect(array('action'=>'index'));
		}
		$orders = $this->Order->find('first', array(
				'recursive' => 2,
				'conditions' => array('Order.id' => $id)
		));
		if (!empty($orders)) {
			$this->set('lang','vie');
			$this->set('abc',$orders);
		}
		else {
			$this->redirect(array('action'=>'index'));
		}
	}
}
?>
